package com.itheima.steawmdemo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo9 {
    public static void main(String[] args) {
        ArrayList<String> manList = new ArrayList<>();
        manList.add("张国立");
        manList.add("张晋");
        manList.add("刘烨");
        manList.add("郑伊健");
        manList.add("徐峥");
        manList.add("王宝强");

        ArrayList<String> womanList = new ArrayList<>();
        womanList.add("郑爽");
        womanList.add("杨紫");
        womanList.add("关晓彤");
        womanList.add("张天爱");
        womanList.add("杨幂");
        womanList.add("赵丽颖");

        // 男演员只要三个字的前两人
        Stream<String> manStream = manList.stream().filter(s -> s.length() == 3).limit(2);
        // 女演员只要姓杨的，且不要第一个
        Stream<String> womanStream = womanList.stream().filter(s -> s.startsWith("杨")).skip(1);
        // 合并2个流，并封装成 Actor 对象，然后打印
        Stream.concat(manStream, womanStream).forEach(name -> System.out.println(new Actor(name)));
    }
}
